Skip to main content

Multiple Linear Regression

Linear regression is a statistical modeling technique used to understand and analyze the relationship between a dependent variable and one or more independent variables. It assumes a linear relationship between the variables, meaning that the dependent variable can be expressed as a linear combination of the independent variables.

Method: POST Authorization: API Key
https://engine.raccoon-ai.io/api/v1/ml/regression/mlr

Authorization

TypeKeyValue
API KeyX-Api-Keyrae_######

Request Body

SectionKeyData TypeRequiredDescription
traindatajsontrueData that use to train the model
featureslisttrueInput features (X)
targetslisttrueOutput targets (y)
configjsonfalseTrain configurations
predictdatajsontrueData that need to predicted by the trained model
configjsonfalsePredict configurations

Types

{
"train" : {
"data" : <json_data>,
"features": <list>,
"targets" : <list>,
"config" : {
"std_scale": <boolean>,
"encoder" : <"onehot" | "label" | "drop">,
"val_size" : <float>
},
"hyper_params": <json>
},
"predict": {
"data": <json_data>,
"config": {
"include_inputs": <boolean>,
"round": <int>
}
}
}

Hyper Parameters

ParameterTypeDefaultDescription
fit_interceptbooltrueWhether to calculate the intercept for this model. If set to False, no intercept will be used in calculations (i.e. data is expected to be centered).
copy_XbooltrueIf True, X will be copied; else, it may be overwritten.
n_jobsintnullThe number of jobs to use for the computation. This will only provide speedup in case of sufficiently large problems, that is if firstly n_targets > 1 and secondly X is sparse or if positive is set to True. None means 1
positiveboolfalseWhen set to True, forces the coefficients to be positive. This option is only supported for dense arrays.

Sample

{
"train": {
"data": {
"R&D Spend": {
"0": 165349.2,
"1": 162597.7,
"2": 153441.51,
"3": 144372.41,
"4": 142107.34,
"5": 131876.9,
"6": 134615.46,
"7": 130298.13,
"8": 120542.52,
"9": 123334.88
},
"Administration": {
"0": 136897.8,
"1": 151377.59,
"2": 101145.55,
"3": 118671.85,
"4": 91391.77,
"5": 99814.71,
"6": 147198.87,
"7": 145530.06,
"8": 148718.95,
"9": 108679.17
},
"Marketing Spend": {
"0": 471784.1,
"1": 443898.53,
"2": 407934.54,
"3": 383199.62,
"4": 366168.42,
"5": 362861.36,
"6": 127716.82,
"7": 323876.68,
"8": 311613.29,
"9": 304981.62
},
"State": {
"0": "New York",
"1": "California",
"2": "Florida",
"3": "New York",
"4": "Florida",
"5": "New York",
"6": "California",
"7": "Florida",
"8": "New York",
"9": "California"
},
"Profit": {
"0": 192261.83,
"1": 191792.06,
"2": 191050.39,
"3": 182901.99,
"4": 166187.94,
"5": 156991.12,
"6": 156122.51,
"7": 155752.6,
"8": 152211.77,
"9": 149759.96
}
},
"features": ["R&D Spend", "Administration", "Marketing Spend", "State"],
"targets": ["Profit"],
"config": {
"std_scale": true,
"encoder": "onehot"
}
},
"predict": {
"data": {
"R&D Spend": {
"0": 165349.2,
"1": 162597.7
},
"Administration": {
"0": 136897.8,
"1": 151377.59
},
"Marketing Spend": {
"0": 471784.1,
"1": 443898.53
},
"State": {
"0": "New York",
"1": "California"
}
},
"config": {
"include_inputs": true,
"round": 2
}
}
}

Reponse Body

KeyData TypeDescription
successbooleanIndicate the success of the request
msgstringMessage indicators
errorstringError information, only set if success is false
resultjsonResult, only set if success is true
scorejsonr2_scores of the training and testing phases, only set if success is true
generated_tsfloatGenerated timestamp

Types

{
"success": <boolean>,
"msg": <string>,
"error": <string>,
"result": <json>,
"score": {
"train": <float>,
"validation": <float>
},
"generated_ts": <timestamp>
}

Sample

{
"success": true,
"msg": "Model trained and predicted successfully",
"error": null,
"result": {
"R&D Spend": {
"0": 165349.2,
"1": 162597.7
},
"Administration": {
"0": 136897.8,
"1": 151377.59
},
"Marketing Spend": {
"0": 471784.1,
"1": 443898.53
},
"State": {
"0": "New York",
"1": "California"
},
"Profit": {
"0": 190209.72,
"1": 186863.18
}
},
"score": {
"train": 0.942446542689397,
"validation": 0.9649618042060305
},
"saved_in": null,
"generated_ts": 1685439220.425382
}